package com.lzh.article.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.lzh.article.entity.ApAuthor;
import com.lzh.article.service.ApAuthorService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
    import com.lzh.core.controller.AbstractCoreController;

/**
* <p>
* APP文章作者信息表 控制器</p>
* @author lzh
* @since 2021-06-24
*/
@RestController
@RequestMapping("/apAuthor")
public class ApAuthorController extends AbstractCoreController<ApAuthor> {

    private ApAuthorService apAuthorService;

    //注入
    @Autowired
    public ApAuthorController(ApAuthorService apAuthorService) {
        super(apAuthorService);
        this.apAuthorService = apAuthorService;
    }

    /**
     * 根据ApUser 的id获取作者
     * @param id
     * @return
     */
    @GetMapping("/one")
    public ApAuthor getByUserId(@RequestParam(value = "id") Integer id) {
        QueryWrapper<ApAuthor> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("user_id",id);
        ApAuthor author = apAuthorService.getOne(queryWrapper);
        return author;
    }

}

